<template>
<div>
  <div class="info-desc">
    <div class="start"></div>
    <div class="desc">{{detailInfo.desc}}</div>
    <div class="end"></div>
  </div>
  <div  class="info-key">{{text}}</div>
  <div class="info-list">
    <img v-for="(item,index) in newArr" :key="index" :src="item" @load="imgLoad" alt="">
  </div>
</div>
</template>

<script>
export default {
name: "DetailGoodsInfo",
  data(){
    return{
      text:'',
      newArr:[],
      counter: 0,
      imagesLength: 0
    }
  },
  props:{
    detailInfo:{
      type:Object,
      default(){
        return {
          detailImage:[{
            list:[]
          }]
        }
      }
    }
  },
  watch:{
    detailInfo(){
      this.text = this.detailInfo.detailImage[0].key
      this.newArr = this.detailInfo.detailImage[0].list
      // 获取图片的个数
      this.imagesLength = this.detailInfo.detailImage[0].list.length
    }
  },methods:{
    imgLoad(){
      // 判断, 所有的图片都加载完了, 那么进行一次回调就可以了.
      if (++this.counter === this.imagesLength) {
       // console.log('发送刷新')
        this.$emit('imgLoad');
      }

    }
  },computed:{



  }
}
</script>

<style scoped>
.info-desc {
  padding: 0 15px;
}

.info-desc .start, .info-desc .end {
  width: 90px;
  height: 1px;
  background-color: #a3a3a5;
  position: relative;
}

.info-desc .start {
  float: left;
}
.info-desc .end {
  float: right;
}

.info-desc .start::before, .info-desc .end::after {
  content: '';
  position: absolute;
  width: 5px;
  height: 5px;
  background-color: #333;
  bottom: 0;

}
.info-desc .end::after {
  right: 0;
}

.info-desc .desc {
  padding: 15px 0;
  font-size: 14px;
}

.info-key {
  margin: 10px 0 10px 15px;
  color: #333;
  font-size: 15px;
}


.info-list img {
  width: 100%;
}
</style>